package cn.gson.boot.model.dao;

import cn.gson.boot.model.pojos.Hetong;
import cn.gson.boot.model.pojos.Jiaofujihua;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;
import java.util.List;

public interface JiaoFuJiHuaDao extends CrudRepository<Jiaofujihua,Integer> {
    //根据合同id来移除合同 （逻辑删除）
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update jiaofujihua set jj_ys=0 where jj_id=?1")
    public void yichuJiaoFuJiHua(Integer jjId);
    //根据合同id来移除合同 （物理删除）
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "delete from jiaofujihua  where jj_id=?1")
    public void deleteJiaoFuJiHua(Integer jjId);
    /*//新建交付计划
    @Query(nativeQuery = true,value = "select * from hetong where ht_zhuangtai = '执行中' and ht_ys = 1 order by ht_id desc")
    public List<Jiaofujihua> addJiaoFuJiHua();*/


    //修改交付计划的状态(根据交计id)
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update jiaofujihua set jj_tixing=?1 where jj_id=?2")
    public void updateJiaoFuJiHuaZt(String zt,Integer jjId);

}
